package cn.edu.tju.fctl.service.impl;

import cn.edu.tju.fctl.dao.MarkMapper;
import cn.edu.tju.fctl.dao.UserMapper;
import cn.edu.tju.fctl.entities.Mark;
import cn.edu.tju.fctl.entities.User;
import cn.edu.tju.fctl.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by catold on 15/12/17.
 */
@Service
public class UserService implements IUserService {
    @Autowired
    UserMapper userMapper;
    @Autowired
    MarkMapper markMapper;

    public User findById(int id) {
        return userMapper.selectByPrimaryKey(id);
    }

    public User findByNameAndPwd(String number, String pwd) {
        return userMapper.findByNumberAndPwd(number, pwd);
    }

    public User findByNumber(String number) {
        return userMapper.findByNumber(number);
    }

    public int updateUser(User user){
        return userMapper.updateByPrimaryKey(user);
    }

    public List<Mark> findUserMarks(int id) {
        return markMapper.selectByUserID(id);
    }
}